

<template>
<mu-paper :z-depth="1" class="lan-loadmore-body">
  <mu-appbar color="primary" class="lan-header">
      <mu-button icon slot="left" v-close>
        <i class="iconfont angle-left iconangle-left"></i>
        <span class="lan-header-back">返回</span>
      </mu-button>
      随机检查
      <mu-button icon slot="right" >
        <!-- <span class="text">本地保存</span> -->
      </mu-button>
    </mu-appbar>
  <mu-container ref="container" class="lan-loadmore-content no-padding">
    <mu-form :model="form" class="mu-lan-form" :label-position="'left'" label-width="">
          <mu-form-item label="项目名称" class="form-between required" >
            <span class="normal-font-size form-right-text" @click="goSelectProject" >{{form.orgName?form.orgName:'请选择'}}</span>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <mu-form-item label="检查类型" class="required">
            <mu-select
              v-model="form.checkTypeId"
              placeholder="请选择"
              popover-class="lan-popover-select"
            >
              <mu-option
                v-for="(list,index) in checkTypeList"
                :key="index"
                :label="list.name"
                :value="list.id"
              ></mu-option>
            </mu-select>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <mu-form-item label="所属区域" class="form-between required" >
            <span class="normal-font-size form-right-text" @click="openArea">{{form.areaName?form.areaName:'请选择'}}</span>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <mu-form-item label="检查部位" class="inline-item required">
            <mu-text-field v-model="form.checkParts" multi-line placeholder="请输入" :rows="3" :rows-max="6" ></mu-text-field>
          </mu-form-item>
          
          <mu-form-item label="使用检查指导表" class="form-between required">
            <mu-switch style="height:auto;overflow-y:hidden;"  v-model="form.useTable" @change="tableChange" :disabled="!form.orgName || !form.areaName"></mu-switch>
            <!-- <mt-switch v-model="form.useTable"></mt-switch> -->
          </mu-form-item>
          <mu-form-item label="检查指导表" class="form-between required" v-show="form.useTable">
            <span class="normal-font-size form-right-text" @click="openTable">{{`已选${this.form.tableRecList.length}个`}}</span>
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <!-- 选择的检查指导表 -->
          <div v-show="form.useTable && form.tableRecList.length>0" >
            <showTableopeat v-for="(item,index) in form.tableRecList" :has="index == form.tableRecList.length-1" :key="index" v-model="form.tableRecList[index]" :areaDetail="areaDetail" :projectData="customRoot"></showTableopeat>
          </div>

          <!-- 无表的情况 -->
          <noTable @add="qAdd" @plus="qPlus" v-if="form.orgId && areaDetail['id'] && !form.useTable" v-model="form.notableData" :areaDetail="areaDetail" :projectData="customRoot"></noTable>

          <mu-form-item label="检查人签名" class="form-between " >
            <span class="normal-font-size form-right-text" @click="opensign">{{signatureList.length?'已签名':'请签名'}}</span>
            <!-- <mu-text-field  placeholder="请输入"></mu-text-field> -->
            <i class="iconfont angle-left iconangle-right"></i>
          </mu-form-item>
          <mu-form-item  class="form-between" v-if="signatureList.length > 0">
            <div v-for="(item,index) in signatureList" :key="index" class="img-box">
              <img :src="item" :preview="index" />
              <mu-icon class="close" value="close" @click="deletesign(index)"></mu-icon>
            </div>
          </mu-form-item>
          <mu-form-item class="form-submit">
            <!-- <mu-button color="primary">重置</mu-button> -->
            <mu-button full-width color="primary" @click="saveData">提交</mu-button>
          </mu-form-item>
        </mu-form>
        
  </mu-container>
  <!-- 选检查表 -->
  <mu-dialog
      width="100%"
      transition="slide-right"
      fullscreen
      :open.sync="alltableCon"
      class="lan-dialog"
    >
    <allTable v-if="alltableCon" :checkedList="tableIds" @cancel="alltableCon = false" @ok="getSomeTable"></allTable>
  </mu-dialog>

  <!-- 选项目 -->
  <Org ref="org" v-if="pojectOpen" :open="pojectOpen" :customRoot="customRoot" :orgType="orgTypeSelect" @change="orgChange" @close="pojectOpen = false" @confirm="pojectOpen = false"></Org>
 
  <!-- 选择区域 -->
  <mu-dialog
      width="100%"
      transition="slide-right"
      fullscreen
      :open.sync="areaController"
      class="lan-dialog"
    >
      <mu-appbar color="primary" class="lan-header">
        <mu-button icon slot="left" @click="areaController = false">
          <i class="iconfont angle-left iconangle-left"></i>
          <span class="lan-header-back">返回</span>
        </mu-button>区域
      </mu-appbar>
      <div class="lan-dialog-body no-padding">
        <mTree
          v-if="areaController"
          :data="tree.data"
          :props="tree.defaultProps"
          :clickableConditions="tree.clickableConditions"
          @click="skipPage"
        ></mTree>
      </div>
  </mu-dialog>
  <!-- 签名 -->
  <mu-dialog
      width="100%"
      transition="slide-right"
      fullscreen
      :open.sync="signature"
      class="lan-dialog"
    >
    <div style="height:100%;width:100%;" >
      <Signature v-if="signature"  @close="signature = false" @success="signatureBack"></Signature>
    </div>
  </mu-dialog>
</mu-paper>
</template>

<script>
import allTable from "./allTable";
import showTableopeat from "./showTableopeat";
import Org from "@/select/org/Org";
import User from "@/select/user/User";
import mTree from "@/tree/mTree";
import noTable from "./noTable";
import Signature from "@/signature/Signature";
export default {
	name: 'check',
	components: {
    allTable,showTableopeat,Org,User,mTree,noTable,Signature
	},
  data() {
    return {
      form:{
        "areaId": "",//所属区域id
        areaName:'',
        "checkFrequency": '',//检查频率
        "checkParts": "",//任务所属部委
        "checkResult":'0',//检查结果
        "checkTypeId": "",//检查类型id
        checkType:'',
        notableData:{
          checkResult:'0',//检查结果 0无问题 1有问题
          scenePhotos:[],//现场照片
          checkCopyUserIds:[],//抄送人
          problemList:[{
            "problemTypeId": "", //--问题类型id
            "problemElseRemark": "", //--问题类型选则其它时候的备注
            "problemLevel": '1', //--问题等级 1一般 2较大 3重大
            "scenePhotos": [], ////--现场照片 格式['1','2']
            "floorPlanTag": [], //--平面图标记
            "problemDescription": "", //--问题描述
            "rectifyDto": {
              "days": '', //--整改天数 0立即整改
              "endTime": "", //--整改期限
              "responsibleUnitId": "", //--整改单位 -- 责任单位
              "responsibleUserId": "", //--整改人
              "rectificationRequirements": "", //--整改要求
              "rectificationResult":"",//整改结果描述
              "reviewUser": "",// --复查人
              "isCurrentRect": '0',// --问题必传参数 是否现场整改 0是 1否
              "rectCopyUserIds": []///--整改抄送人
                
            }
          }],
        },
        checkSignature:'',//签名
        tableRecList:[],
      },
      points:[],
      checkTypeList:[],
      projectList:[],
      questions:[{name:''}],
      tableSelectList:[],
      rateList:['1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31',],
      alltableCon:false,
      tableIds:[],
      pojectOpen:false,
      userOpen:false,
      orgTypeSelect:'currOrgProject',
      userType:'currOrgProject',
      topUserId:'',
      areaController:false,
      tree: {
          defaultProps: {
            id: "id",
            name: "name",
            children: "children"
          },
          clickableConditions: {
            all: {
              //所有的是否可以点击
              enable: true
            },
            part: {
              //部分的可以点击的条件
              prop: "orgType",
              value: [1]
            }
          },
          data: []
        },
        customRoot:[],
        areaDetail:{},
        signature:false,
        signatureList:[]
      
    };
  },
  async created() {
    // this.projectList = await this.$A.comData("projectList");
    let nowinfo = this.$A.GS('orgInfo')
    if(nowinfo['type'] == 1){
      this.form.orgName = nowinfo['orgName']
      this.form.orgId = nowinfo['orgId']
      this.customRoot = [{type:'1',value:nowinfo['orgId'],label:nowinfo['orgName']}]
      this.orgTypeSelect = 'currOrgProject'
      this.loadTreeData()
    }
    this.checkTypeList = await this.$A.comData("checkTypeList");
  },
  mounted() {},
  methods: {
    qAdd(){
      this.form.notableData.problemList.push({
            "problemTypeId": "", //--问题类型id
            "problemElseRemark": "", //--问题类型选则其它时候的备注
            "problemLevel": '1', //--问题等级 1一般 2较大 3重大
            "scenePhotos": [], ////--现场照片 格式['1','2']
            "floorPlanTag": [], //--平面图标记
            "problemDescription": "", //--问题描述
            "rectifyDto": {
              "days": '', //--整改天数 0立即整改
              "endTime": "", //--整改期限
              "responsibleUnitId": "", //--整改单位 -- 责任单位
              "responsibleUserId": "", //--整改人
              "rectificationRequirements": "", //--整改要求
              "rectificationResult":"",//整改结果描述
              "reviewUser": "",// --复查人
              "isCurrentRect": '0',// --问题必传参数 是否现场整改 0是 1否
              "rectCopyUserIds": [ ]///--整改抄送人
                
            }
          })
    },
    qPlus(index){
      this.form.notableData.problemList.splice(index,1)
    },
    opensign(){
      if(this.signatureList.length>0){
        return;
      }
      this.signature = true
    },
    deletesign(index){
      this.signatureList.splice(index,1)
      this.form.checkSignature = ''
    },
    signatureBack(url){
      this.signatureList.push(url)
      this.signature = false;
      this.form.checkSignature = url;
    },
    openArea(){
      if(!this.form.orgId){
        this.$A.MS("请先选择项目")
        return;
      }
      this.areaController = true;
    },
    skipPage(value){
      console.log(value)
      this.form.areaName = value.name
      this.form.areaId = value.id
      this.areaController = false;
      this.getProjectUnit(value.id)
    },
    goSelectProject(){
      this.customRoot = []
      this.orgTypeSelect = 'currOrgProject'
      this.pojectOpen = true
    },
    orgChange(value){
        this.form.orgId = value[0].id || value[0].value
        this.form.orgName = value[0].projectName || value[0].label
        this.customRoot = [{type:'1',value:this.form.orgId,label:this.form.orgName}]
        this.loadTreeData()
     
      
    },
    //获取区域所带的责任单位和责任人
    getProjectUnit(id){//areaDetail
      this.$A.Go("get", '/safety/projectArea/detail', {id}).then(
          response => {
            if (response.code == 200) {
              this.areaDetail = response.body || {};
              
              
            } else {
              this.$A.MS(response.msg)
            }
            this.$closeLoading();
          },
          err => {
            this.$closeLoading();
            console.log(err);
          }
        );
    },
    //增加问题
    addQues(){
      this.questions.push({name:''})
    },
    deleteQues(index){
      this.questions.splice(index,1)
    },
    tableChange(value){
      // console.log(value)
      if(value){//使用检查指导表
        this.questions = [{name:''}]
      }else{//使用问题
        this.tableSelectList = []
      }
    },
    openTable(){
      if(this.form.tableRecList.length>0){
        this.tableIds = this.form.tableRecList.map(o=>o.id)
      }
      this.alltableCon = true;

    },
    getSomeTable(list = []){
      console.log(list)
      let arr = JSON.parse(JSON.stringify(list));
      let data = [];
      let sq = 0 ;
      for(let i=0; i<arr.length; i++){
        // arr[i]['problemList'] = []
        for(let j=0; j<arr[i]['detailInfo']['itemContentList'].length; j++){
          for(let q=0; q<arr[i]['detailInfo']['itemContentList'][j]['contentList'].length;q++){
            arr[i]['detailInfo']['itemContentList'][j]['contentList'][q]['problemList'] = {}
            arr[i]['detailInfo']['itemContentList'][j]['contentList'][q]['has'] = '0'
            arr[i]['detailInfo']['itemContentList'][j]['contentList'][q]['sq'] = sq;
            sq ++;
          }
          
        }
        arr[i]['detailInfo']['scenePhotos'] = []
        arr[i]['detailInfo']['copyUserIds'] = []
        arr[i]['detailInfo']['checkResult'] = '0'
        data.push(arr[i]['detailInfo'])
      }
      // this.tableSelectList = list
      console.log(data)
      this.form.tableRecList = data;
      this.alltableCon = false
    },
    loadTreeData() {
        this.$openLoading();
        let params = {
          orgId: this.form.orgId,
          type: '1',
        };
        this.$A.Go("get", '/safety/projectArea/tree', params).then(
          response => {
            if (response.code == 200) {
              this.tree.data = response.body || [];
              // this.dataPool = response.body;
            } else {
              this.$A.MS(response.msg)
            }
            this.$closeLoading();
          },
          err => {
            this.$closeLoading();
            console.log(err);
          }
        );
    },
    saveData(){
      let quesList = [],quesList2 = [],tableList2 = [];
      if(!this.form.orgId){
        this.$A.MS('请选择项目')
        this.form.orgId = ''
        this.form.orgName = ''
        return;
      }
      if(!this.form.checkTypeId){
        this.$A.MS('请选择检查类型')
        this.form.checkTypeId = ''
        this.form.checkType = ''
        return;
      }
      if(!this.form.areaId){
        this.$A.MS('请选择区域')
        this.form.areaId = ''
        this.form.areaName = ''
        return;
      }
      if(!this.form.checkParts){
        this.$A.MS('请填写检查部位')
        this.form.checkParts = ''
        return;
      }
     
      if(this.form.useTable){
        if(this.form.tableRecList.length <= 0){
          this.$A.MS('请选择检查指导表')
          this.form.tableIds = []
          return ;
        }else{//这是有表的情况---分两种 1，无问题，2有问题
          //先处理有问题的
          // this.form.tableIds = this.tableSelectList.map(o=>o.id)
          console.log(this.form.tableRecList)
          // return;
          let problemList = [];
          let tablist = [];
          let data = this.form.tableRecList;//有几个表
          for(let i=0;i<data.length;i++){
            for(let j=0;j<data[i]['itemContentList'].length;j++){
              for(let q=0;q<data[i]['itemContentList'][j]['contentList'].length;q++){
                if(data[i]['itemContentList'][j]['contentList'][q]['has'] == 1){
                  problemList.push({
                    checkTableId:data[i]['id'],
                    checkItemId:data[i]['itemContentList'][j]['itemId'],
                    checkContentId:data[i]['itemContentList'][j]['contentList'][q]['contentId'],
                    ...data[i]['itemContentList'][j]['contentList'][q]['problemList']
                  })
                  tablist.push({
                    checkTableId:data[i]['id'],
                    item:data[i]['itemContentList'][j]['item'],
                    itemContent:JSON.stringify([{key:data[i]['itemContentList'][j]['contentList'][q]['contentName'], value:'有问题'}])
                  })
                }else{
                  tablist.push({
                    checkTableId:data[i]['id'],
                    item:data[i]['itemContentList'][j]['item'],
                    itemContent:JSON.stringify([{key:data[i]['itemContentList'][j]['contentList'][q]['contentName'], value:'无问题'}])
                  })
                }
                
              }
            }
            if(problemList.length){//这个有问题
              quesList2.push(...problemList)
              problemList = [];
            }else{//这个表没问题
              //检测几个必填
              console.log(data[i]['scenePhotos'])
              console.log(data[i]['copyUserIds'])
              if(data[i]['scenePhotos'] && data[i]['scenePhotos'].length){
                !this.form.scenePhotos && (this.form.scenePhotos = []);
                this.form.scenePhotos.push(...data[i]['scenePhotos']);
              }
              if(data[i]['copyUserIds'] && data[i]['copyUserIds'].length){
                !this.form.checkCopyUserIds && (this.form.checkCopyUserIds = []);
                this.form.checkCopyUserIds.push(...data[i]['copyUserIds'])
              }
            }
          }
          if(!quesList2.length){
            if(!this.form.scenePhotos || !this.form.scenePhotos.length){
              this.$A.MS('请上传现场照片')
              return;
            }
            if(!this.form.checkCopyUserIds || !this.form.checkCopyUserIds.length){
              this.$A.MS('请选择抄送人')
              return;
            }
          }
          //  "problemTypeId": "", //--问题类型id
          //   "problemElseRemark": "", //--问题类型选则其它时候的备注
          //   "problemLevel": '1', //--问题等级 1一般 2较大 3重大
          //   "scenePhotos": [], ////--现场照片 格式['1','2']
          //   "floorPlanTag": [], //--平面图标记
          //   "problemDescription": "", //--问题描述
          //   "rectifyDto": {
          //     "days": 0, //--整改天数 0立即整改
          //     "endTime": "", //--整改期限
          //     "responsibleUnitId": "", //--整改单位 -- 责任单位
          //     "responsibleUserId": "", //--整改人
          //     "rectificationRequirements": "", //--整改要求
          //     "reviewUser": "",// --复查人
          //     "isCurrentRect": '0',// --问题必传参数 是否现场整改 0是 1否
          //     "rectCopyUserIds": [ ]///--整改抄送人
                
          //   }
          //检查是否有空值
          for(let i =0;i<quesList2.length;i++){
            if(quesList2[i]['problemTypeId']){
              if(quesList2[i]['problemTypeId'] == '-1' && !quesList2[i]['problemElseRemark']){
                this.$A.MS('请填写问题备注')
                return;
              }
            }else{
              this.$A.MS('请选择问题类型')
              return;
            }
            
            if(!quesList2[i]['problemDescription']){
              this.$A.MS('请填写问题描述')
              return;
            }
            
            if(!quesList2[i]['rectifyDto']['days'] && quesList2[i]['rectifyDto']['days'] != '0'){
              this.$A.MS('请选择整改期限')
              return;
            }
            //???????
            if(!quesList2[i]['scenePhotos'] || !quesList2[i]['scenePhotos'].length){
              this.$A.MS('请上传现场照片')
              return;
            }
            if(!quesList2[i]['rectifyDto']['rectificationResult'] && quesList2[i]['rectifyDto']['days'] == '0'){
              this.$A.MS('请填写整改结果描述')
              return;
            }
            if(!quesList2[i]['rectifyDto']['responsibleUnitId']){
              this.$A.MS('请选择责任单位')
              return;
            }
            
            if(!quesList2[i]['rectifyDto']['responsibleUserId']){
              this.$A.MS('请选择整改人')
              return;
            }
            if(!quesList2[i]['rectifyDto']['rectificationRequirements']){
              this.$A.MS('请填写整改要求')
              return;
            }
            
            if(!quesList2[i]['rectifyDto']['reviewUser'] && quesList2[i]['rectifyDto']['days'] != '0'){
              this.$A.MS('请选择复查人')
              return;
            }
            if(!quesList2[i]['rectifyDto']['rectCopyUserIds'] || !quesList2[i]['rectifyDto']['rectCopyUserIds'].length){
              this.$A.MS('请选择抄送人')
              return;
            }
          }
          tableList2 = tablist;
        }
      }else{
        //无问题
        
        if(this.form.notableData.checkResult == 0){//现场照片，和抄送人
          this.form.problemList = []
          this.form.checkResult = '0'
          if(!this.form.notableData.scenePhotos.length){
            this.$A.MS('请上传图片')
            return;
          }else{
            this.form.scenePhotos = this.form.notableData.scenePhotos
          }
          //抄送人
          if(!this.form.notableData.checkCopyUserIds.length){
            this.$A.MS('请选择抄送人')
            return;
          }else{
            this.form.checkCopyUserIds = this.form.notableData.checkCopyUserIds
          }
        }else{//有问题的时候
          this.form.checkResult = '1'
          //后续
          if(!this.form.notableData.problemList.length){
            // this.$A.MS('请选择抄送人')
            return;
          }else{//检测问题
            let data = this.form.notableData.problemList,arr=[],con = false;
            for(let i=0;i<data.length;i++){
              if(!data[i]['problemTypeId'] && !data[i]['problemElseRemark']){//问题类型
                this.$A.MS('请选择问题类型')
                con = true
                break;
              }
              if(!data[i]['problemLevel']){//问题等级
                this.$A.MS('请选择问题等级')
                con = true
                break;
              }
            
              if(!data[i]['problemDescription']){//问题描述
                this.$A.MS('请填写问题描述')
                con = true
                break;
              }
              if(!data[i]['floorPlanTag'] || !data[i]['floorPlanTag'].length){//问题描述
                this.$A.MS('请标记点位')
                con = true
                break;
              }
              //平面图标记 跳过 需要处理
              if(!data[i]['rectifyDto']['days'] && data[i]['rectifyDto']['days'] != '0'){//整改期限
                this.$A.MS('请选择整改期限')
                con = true
                break;
              }
              if(!data[i]['rectifyDto']['rectificationRequirements']){//整改要求
                this.$A.MS('请填写整改要求')
                con = true
                break;
              }
              
              if(!data[i]['rectifyDto']['responsibleUnitId']){//责任单位
                this.$A.MS('请选择责任单位')
                con = true
                break;
              }
              if(!data[i]['scenePhotos'].length){//现场照片
                this.$A.MS('请上传现场照片')
                con = true
                break;
              }
              if(!data[i]['rectifyDto']['rectificationResult'] && data[i]['rectifyDto']['days'] == '0'){
                this.$A.MS('请填写整改结果描述')
                con = true
                break;
              }
              if(!data[i]['rectifyDto']['responsibleUserId']){//整改责任人
                this.$A.MS('请选择整改责任人')
                con = true
                break;
              }
              
              if(!data[i]['rectifyDto']['reviewUser'] && data[i]['rectifyDto']['days'] != '0'){//复查人
                this.$A.MS('请选择复查人')
                con = true
                break;
              }
              if(!data[i]['rectifyDto']['rectCopyUserIds'].length){//整改抄送人
                this.$A.MS('请选择抄送人')
                con = true
                break;
                
              }
              
              arr.push({
                  "problemTypeId": data[i]['problemTypeId']==-1?'':data[i]['problemTypeId'], //--问题类型id
                  "problemElseRemark": data[i]['problemTypeId']==-1?data[i]['problemElseRemark']:'', //--问题类型选则其它时候的备注
                  "problemLevel": data[i]['problemLevel'], //--问题等级 1一般 2较大 3重大
                  "scenePhotos": JSON.stringify(data[i]['scenePhotos']), ////--现场照片 格式['1','2']
                  "floorPlanTag": data[i]['floorPlanTag'], //--平面图标记
                  "problemDescription": data[i]['problemDescription'], //--问题描述
                  "rectifyDto": {
                    "days": data[i]['rectifyDto']['days'], //--整改天数 0立即整改
                    "endTime": data[i]['rectifyDto']['endTime'], //--整改期限
                    "responsibleUnitId": data[i]['rectifyDto']['responsibleUnitId'], //--整改单位 -- 责任单位
                    "responsibleUserId": data[i]['rectifyDto']['responsibleUserId'], //--整改人
                    "rectificationRequirements": data[i]['rectifyDto']['rectificationRequirements'], //--整改要求
                    "rectificationResult":data[i]['rectifyDto']['rectificationResult'],//整改结果描述
                    "reviewUser": data[i]['rectifyDto']['reviewUser'],// --复查人
                    "isCurrentRect": data[i]['rectifyDto']['days'] == 0?data[i]['rectifyDto']['isCurrentRect']:'1',// --问题必传参数 是否现场整改 0是 1否
                    "rectCopyUserIds": data[i]['rectifyDto']['rectCopyUserIds'] ///--整改抄送人
                    
                  }
              })
            }
            if(con){
              return;
            }
            quesList = arr;
          }

        }
      }
     
      for(let i =0;i<quesList.length;i++){
        if(!quesList[i]['floorPlanTag']){
          quesList[i]['floorPlanTag'] = '' //JSON.stringify('[]')
        }else{
          let arr = [];
          if(quesList[i]['floorPlanTag'].length>0){
            let pp = quesList[i]['floorPlanTag'][0]['left']+','+quesList[i]['floorPlanTag'][0]['top']
            arr = [pp]
          }else{
            arr = ''
          }
          quesList[i]['floorPlanTag'] = arr?JSON.stringify(arr):''
        }
      }
   
      // if(!this.form.checkSignature){
      //    this.$A.MS('请签名')
      //    return;
      // }
      for(let i = 0;i<quesList2.length;i++){
        quesList2[i]['scenePhotos'] = JSON.stringify(quesList2[i]['scenePhotos'])
        let arr = [];
        if(quesList2[i]['floorPlanTag'].length>0){
          let pp = quesList2[i]['floorPlanTag'][0]['left']+','+quesList2[i]['floorPlanTag'][0]['top']
          arr = [pp]
        }else{
          arr = ''
        }
        quesList2[i]['floorPlanTag'] = arr?JSON.stringify(arr):''
        
      }
      let obj = {
        areaId: this.form.areaId,//所属区域id
        orgId: this.form.orgId,
        checkParts: this.form.checkParts,//任务所属部委
        checkTypeId: this.form.checkTypeId,//检查类型id
        checkResult:!this.form.useTable && this.form.checkResult==0?'0':'1',//检查结果 0无问题 1有问题
        scenePhotos:!this.form.useTable?(quesList.length?'[]':JSON.stringify(this.form.scenePhotos || [])):JSON.stringify(this.form.scenePhotos||[]),//现场照片
        checkCopyUserIds:!this.form.useTable?(quesList.length?[]:(this.form.checkCopyUserIds || [])):(this.form.checkCopyUserIds || []),//抄送人
        checkSignature:this.form.checkSignature,
        problemList:!this.form.useTable?quesList:quesList2,
        // {
        //   "problemTypeId": "string", //--问题类型id
        //   "problemElseRemark": "string", //--问题类型选则其它时候的备注
        //   "problemLevel": 0, //--问题等级 1一般 2较大 3重大
        //   "scenePhotos": "string", ////--现场照片 格式['1','2']
        //   "floorPlanTag": "string", //--平面图标记
        //   "problemDescription": "string", //--问题描述
        //   "rectifyDto": {
        //     "days": 0, //--整改天数 0立即整改
        //     "endTime": "2019-12-14T06:55:15.580Z", //--整改期限
        //     "responsibleUnitId": "string", //--整改单位 -- 责任单位
        //     "responsibleUserId": "string", //--整改人
        //     "rectificationRequirements": "string", //--整改要求
        //       "reviewUser": "string",// --复查人
        //     "isCurrentRect": 0,// --问题必传参数 是否现场整改 0是 1否
        //     "rectCopyUserIds": [ ///--整改抄送人
        //       "string"
        //     ],
        //   }
        // }
        tableRecList:tableList2,
      }
      console.log(obj)
      // return ;
      this.$openLoading();
      this.$A.Go('post','/safety/checkTask/submit',obj).then(success=>{
        if(success.code == 200){
          this.$A.MS('提交成功')
          this.$router.back();
        }else{
          this.$A.MS(success.msg)
        }
        this.$closeLoading();
      },err=>{
          console.log(err)
          this.$closeLoading();
      })
    },
  }
};
</script>

<style scoped lang='scss' scoped>
.check {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;

	.header {
		color: #888888;
		background-color: #FFFFFF;
	}

  content {
		z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: auto;
    .mu-tabs {
      background-color: #f5f5f5;
    }
    .demo-text {
      padding: 8px;
      background: #fff;
    }
  }
  
}
.img-box{
    width:0.75rem;
    height:0.75rem;
    margin:0.1rem;
    position: relative;
    img{
      height:100%;
      width:100%;
    }
    .close{
      position: absolute;
      height:0.2rem;
      width:0.2rem;
      line-height:0.2rem;
      font-size:0.15rem;
      top: 0.04rem;
      right: 0.04rem;
      color:#fff;
      border-radius: 50%;
      text-align:center;
      background-color: #FF4242;
    }
  }
</style>
<style scoped lang='scss'>
  .footer-op{
    box-sizing:border-box;
    padding:0.05rem 0;
    margin-top:0 !important;
    overflow:auto;
  }
  .op-texarea{
    .mu-form-item-content{
      .mu-input{
        border:0.01rem solid #e8e8e8;
        border-radius:0.04rem;
        padding:0.05rem;
      }
    } 
  }
 
</style>
